#include <iostream>
#include <vector>
using namespace std;

int Find(vector<int>& parent, int index) {
    if(parent[index] != index) {
        parent[index] = Find(parent, parent[index]);
    }
    return parent[index];
}
void Union(vector<int>& parent, int index1, int index2) {
    parent[Find(parent, index1)] = Find(parent, index2);
}
vector<int> findRedundantConnection(vector<vector<int>>& edges) {
    int n = edges.size();
    vector<int> parent(n+1);
    for(int i = 1; i <= n; ++i) {
        parent[i] = i;
    }
    for(auto e : edges) {
        if(Find(parent, e[0]) != Find(parent, e[1])) {
            Union(parent, e[0], e[1]);
        }else {
            return e;
        }
    }
    return vector<int>{};
}